package com.song.controller;

import com.song.vo.CommonResult;
import com.song.vo.Dto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.websocket.server.PathParam;

/**
 * @Author Klys
 * @Date 2023/5/23 23:05
 * @Description
 * @Version 1.0
 */
@Api(tags = "用户测试控制类")
@RestController
@RequestMapping("/test1")
public class TestController {

//    @Autowired
//    private StringEncryptor encryptor;

    @RequestMapping(value = "/v1/test01", method = RequestMethod.PUT)
    @ApiOperation("test01功能测试")
    public CommonResult test01() {
        return CommonResult.success("用户密码修改成功");
    }

    @RequestMapping(value = "/v1/test02", method = RequestMethod.GET)
    @ApiOperation("test02功能测试")
    public CommonResult test02() {
        return CommonResult.success("t2测试成功！");
    }

    @RequestMapping(value = "/v1/test03", method = RequestMethod.GET)
    @ApiOperation("加密口令获取")
    public CommonResult test03() {
//        System.out.println(value);
//        System.out.println(encryptor.decrypt(value));
        return CommonResult.success("t3测试成功！");
    }

    @RequestMapping(value = "/v1/test04", method = RequestMethod.POST)
    @ApiOperation("token测试")
    public CommonResult test04(HttpServletRequest request, HttpServletResponse response, @RequestBody Dto dto) {
        System.out.println(request.getHeader("token"));
        System.out.println(dto.toString());
        return CommonResult.success("t4测试成功！");
    }


    @GetMapping("/v1/test05")
    @ApiOperation("springsecurity测试")
    @ApiImplicitParams(
            @ApiImplicitParam(type = "String", value = "parm", name = "请求参数")
    )
    public CommonResult test05(@PathParam("parm") String parm) {
        return CommonResult.success();
    }


    @RequestMapping(value = "/v1/test06", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("openfeign测试")
    @ApiImplicitParams(
            @ApiImplicitParam(type = "String", value = "parm", name = "请求参数")
    )
    public CommonResult test06(@PathParam("parm") String parm) {
        return CommonResult.success();
    }
}
